package com.kurumi.medical.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kurumi.medical.datasource.TargetDataSource;
import com.kurumi.medical.mapper.StdDiseaseMapper;
import com.kurumi.medical.pojo.StdDisease;
import com.kurumi.medical.service.BasicDataService;
@Service
public class BasicDataServiceImpl implements BasicDataService {

	@Autowired
	private StdDiseaseMapper stdDiseaseMapper;

	
	@Override
	public List<Map<String, Object>> selectDiseaseDictByOracle() {
		return stdDiseaseMapper.selectDiagDictByOracle();
	}

	@Transactional
	@TargetDataSource(name="ds1")
	@Override
	public void addDiseaseDictToMysql(List<Map<String, Object>> oracleDiseaseDicts) {
		if(CollectionUtils.isEmpty(oracleDiseaseDicts)){
			return;
		}
		StdDisease stdDisease = null;
		stdDiseaseMapper.deleteAllDisease();
		for (Map<String, Object> map : oracleDiseaseDicts) {
			stdDisease = new StdDisease();
			//{CREATE_DATE=2017-05-20 15:26:32.0, ADRG_CODE=GZ1, DIAGNOSIS_CODE=T18.101, APPROVED_INDICATOR=1, DIAGNOSIS_NAME=食管内异物, STD_INDICATOR=1, INPUT_CODE=SGNYW}
			stdDisease.setCode((String)map.get("DIAGNOSIS_CODE"));
			stdDisease.setName((String)map.get("DIAGNOSIS_NAME"));
			stdDisease.setIndexCode((String)map.get("INPUT_CODE"));
			stdDisease.setStatus(1);
			stdDiseaseMapper.insertSelective(stdDisease);
			
			
		}
		
		
		
	}
	
	
	
	
}
